# Makefile for drbd.o
#
# This file is part of DRBD by Philipp Reisner and Lars Ellenberg.
#
# drbd is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# drbd is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with drbd; see the file COPYING.  If not, write to
# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
#

# variables set by configure
DISTRO = @DISTRO@
prefix = @prefix@
exec_prefix = @exec_prefix@
localstatedir = @localstatedir@
datarootdir = @datarootdir@
datadir = @datadir@
sbindir = @sbindir@
sysconfdir = @sysconfdir@
BASH_COMPLETION_SUFFIX = @BASH_COMPLETION_SUFFIX@
UDEV_RULE_SUFFIX = @UDEV_RULE_SUFFIX@
INITDIR = @INITDIR@
LIBDIR = @prefix@/lib/@PACKAGE_TARNAME@
CC = @CC@
CFLAGS = @CFLAGS@
LDFLAGS = @LDFLAGS@
LN_S = @LN_S@

DRBD_LIB_DIR = @DRBD_LIB_DIR@
DRBD_RUN_DIR = @DRBD_RUN_DIR@
DRBD_LOCK_DIR = @DRBD_LOCK_DIR@
DRBD_CONFIG_DIR = @DRBD_CONFIG_DIR@

# features enabled or disabled by configure
WITH_83_SUPPORT = @WITH_83_SUPPORT@
WITH_84_SUPPORT = @WITH_84_SUPPORT@
WITH_WINDRBD = @WITH_WINDRBD@
WITH_UDEV = @WITH_UDEV@
WITH_XEN = @WITH_XEN@
WITH_PACEMAKER = @WITH_PACEMAKER@
WITH_RGMANAGER = @WITH_RGMANAGER@
WITH_BASHCOMPLETION = @WITH_BASHCOMPLETION@

# for some reason some of the commands below only work correctly in bash,
# and not in e.g. dash. I'm too lazy to fix it to be compatible.
SHELL=/bin/bash

# variables meant to be overridden from the make command line
ifeq ($(WITH_WINDRBD),yes)
DESTDIR ?=
else
DESTDIR ?= /
endif

CFLAGS += -Wall -I../../drbd-headers -I.. -I.
ifeq ($(WITH_WINDRBD),yes)
CFLAGS += -I../windrbd-compat-headers -DWINDRBD
endif
CFLAGS += $(EXTRA_CFLAGS)

.PHONY: drbd_buildtag.h drbd_buildtag.c

all: drbdmeta_scanner.c drbd_buildtag.c

drbd_buildtag.h:
	./drbd_buildtag.sh $@

drbd_buildtag.c: drbd_buildtag.h
	./drbd_buildtag.sh $@

drbdmeta_scanner.c: drbdmeta_scanner.fl drbdmeta_parser.h
	flex -s -odrbdmeta_scanner.c drbdmeta_scanner.fl

# drbdmeta is in this directory; but some header files it depends on are in 
# v9, so that's where it gets built and installed.

clean:
	rm -f drbdmeta_scanner.c
	! test -e ../../.git || rm -f drbd_buildtag.[ch]

distclean: clean

install: ; @true

uninstall: ; @true

.PHONY: install uninstall clean distclean
../../configure:
	@echo "please (re-)run ./autogen.sh with appropriate arguments"; exit 1
../../config.status: ../../configure
	@echo "please (re-)run ./configure with appropriate arguments"; exit 1
Makefile.in: ;
Makefile: Makefile.in ../../config.status
	cd ../.. && ./config.status user/shared/Makefile

